<?php
/**
 * Created by PhpStorm.
 * User: lzh
 * Date: 2018/4/8
 * Time: 12:39
 */

namespace App\Http\ViewComposers;

use App\Breed;
use Illuminate\Contracts\View\View;

class CatFormComposer {

    protected $breeds;

    public function __construct (Breed $breed) {
        $this->breeds = $breed; // 这里是怎么找到数据库中所有记录的？？？
    }

    public function compose(View $view) {
        $view->with('breeds', $this->breeds->pluck('name', 'id')->all());
    }
}